<?php

namespace app\home\controller;

use app\common\controller\ApiController;
use app\home\service\ApiSellService;
use think\Db;

class Apisell extends ApiController
{
    /**
    * 密码登录
    */
    public function pass_login()
    {
        $phone = input('phone');//手机号
        $password = input('password');//密码
        $result = ApiSellService::pass_login($phone, $password);
        return json($result);
    }

    /**
    * 退出
    */
    public function logout()
    {
        $token = input('token');
        $result = ApiSellService::logout($token);
        return json($result);
    }

    /**
    * 手机验证码登录
    */
    public function phone_login()
    {
        $phone = input('phone');
        $code = input('code');
        $result = ApiSellService::phone_login($phone, $code);
        return json($result);
    }

    /**
    * 发送手机验证码
    */
    public function send_code()
    {
        $phone = input('phone');
        $result = ApiSellService::send_code($phone);
        return json($result);
    }

    /**
    * 忘记密码
    */
    public function forget_pass()
    {
        $phone = input('phone');
        $code = input('code');
        $newpassword = input('newpassword');
        $repassword = input('repassword');
        $result = ApiSellService::forget_pass($phone, $code, $newpassword, $repassword);
        return json($result);
    }

    /**
    * 修改密码
    */
    public function change_pass()
    {
        $token = input('token');
        $old_pass = input('old_pass');
        $new_pass = input('new_pass');
        $re_pass = input('re_pass');
        $result = ApiSellService::change_pass($token, $old_pass, $new_pass, $re_pass);
        return json($result);
    }

    /**
    * 修改头像
    */
    public function upload_img()
    {
        $token = input('token');
        $file = request()->file('file');
        $result = ApiSellService::upload_img($token, $file);
        return json($result);
    }

    /**
    * 订单列表
    */
    public function order_list()
    {
        $token = input('token');
        $page = input('page');
        $result = ApiSellService::order_list($token, $page);
        return json($result);
    }

    /**
    * 订单详情
    */
    public function order_detail()
    {
        $token = input('token');
        $order_id = input('order_id');
        $result = ApiSellService::order_detail($token, $order_id);
        return json($result);
    }

    /**
    * 交易额列表
    */
    public function transaction_list()
    {
        $token = input('token');
        $sellsite_id = input('sellsite_id');
        $result = ApiSellService::transaction_list($token, $sellsite_id);
        return json($result);
    }

    /**
    * 个人交易额信息
    */
    public function sell_info()
    {
        $token = input('token');
        $result = ApiSellService::sell_info($token);
        return json($result);
    }

    /**
     * 安卓上传短视频
     */
    public function insert_video()
    {
        $token = input('token');
        $title = input('title');
        $video_image = request()->file('video_image');
        $video_file = request()->file('video_file');
        $width = input('width');
        $height = input('height');
        $result = ApiSellService::insert_video($token, $title, $video_image, $video_file, $width, $height);
        return json($result);
    }

}